<div class="contextual">
  <%= link_to_if_authorized l(:label_invoice_new), {:controller => 'invoices', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
</div>

<h2><%= l(:label_invoice_plural) %></h2>

<div class="filters">   
	<%= form_tag({:contoller => "invoices", :action => "index"}, :method => :get,  :id => "query_form") do %> 
		<%= hidden_field_tag('project_id', @project.to_param) if @project %>   
		<% no_filters = is_no_filters %>	
	
	<fieldset id="filters" class="collapsible <%= 'collapsed' if no_filters %>">
		<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
		<div style="<%= 'display: none;' if no_filters %>">  
			<p>  
        <span class="filter-condition">        
					<%= label_tag l(:label_invoice_status) + " "  %>
					<%= select_tag :status_id, collection_for_invoice_status_for_select(params[:status_id]) %>
        </span>
        <span class="filter-condition">        
          <%= label_tag l(:field_invoice_date) + " "%>
  				<%= select_tag 'period', options_for_period_select(params[:period]) %>
        </span>
        <span class="filter-condition">        
          <%= label_tag l(:field_invoice_due_date) + " " %>
          <%= text_field_tag :due_date, params[:due_date] %><%= calendar_for('due_date') %>
        </span>
        <% if @project %>
        <span class="filter-condition">        
				<%= label_tag l(:label_contact) + " "  %> 
				<%= select_tag :contact_id, options_for_select(@project.contacts.collect{|u| [u.name, u.id.to_s]}.insert(0, [""]),  params[:contact_id]) %>
        </span>
        <span class="filter-condition">        
				<%= label_tag l(:label_assigned_to) + " "  %> 
				<%= select_tag :assigned_to_id, options_for_select(@project.assignable_users.collect{|u| [u.name, u.id.to_s]}.insert(0, [""]),  params[:assigned_to_id]) %>
        </span>
        <% end %>
			</p>    

		</div>
	</fieldset> 
	<p class="buttons hide-when-print">
		<%= link_to l(:button_apply), "#", :onclick=>"$('#query_form').submit()", :class => 'icon icon-checked' %>
    	<%= link_to l(:button_clear), { :set_filter => 1, :project_id => @project }, :class => 'icon icon-reload'  %>
	</p>                                                                    
	<% end %>  

</div>

<div id="contact_list" class="invoice_list">  
<% if @invoices.empty? %>
    <p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
  	<%= render :partial => RedmineContactsInvoices.settings[:excerpt_invoice_list] ? 'excerpt_list' : 'list' %>
  	<p class="pagination"><%= pagination_links_full @invoices_pages, @invoices_count %></p>
<% end %>
</div>  

                     
<% html_title l(:label_invoice_plural) %>                                                                     

<%= context_menu url_for( {:controller => "invoices", :action => "context_menu"} )%>  

<% content_for :sidebar do %>
  <%= render :partial => 'stat_invoiced' %>
  <%= render :partial => 'stat_status' %>
<% end %>

<% content_for :header_tags do %>
	<%= stylesheet_link_tag :contacts_invoices, :plugin => 'redmine_contacts_invoices' %> 
	<%= stylesheet_link_tag :contacts, :plugin => 'redmine_contacts' %>
	<meta name = "format-detection" content = "telephone=no">
<% end %>

